<?php
	require '../tools.func.php';
	require '../db.func.php';
	require  'auth.php';
	require 'head.php';

	 
	$pan=getsession('admin');
	if(empty($_POST['adminpass'])){
		 setinfo('请输入旧密码');
	}
	else{
		 $newpass=htmlentities($_POST['newpass']);
		  $okpass=htmlentities($_POST['okpass']);
		  $adminpass=htmlentities($_POST['adminpass']);
		  $pan1=getsession('admin');
		  if($newpass==$okpass){
		  	   $prefix=getprefix();
		  		$sql="SELECT adminpass FROM {$prefix}admin WHERE id='{$pan1['id']}' AND adminpass='$adminpass'";
		  		$pan2=queryone($sql);
		  		if($pan2){
		  		$sq="UPDATE {$prefix}admin SET adminpass ='$okpass' WHERE id='{$pan1['id']}'";
		  				$pan3=execute($sq);
		  				setinfo('密码修改成功');
		  		}
		  		else{
		  			setinfo('旧密码不正确');
		  		}
		  }	
		  else{
		  	 setinfo('输入的密码不一致');
		  }
	}
?>
				
	<div class="row">
	<div class="col-md-12">
	<div class="card">
	<div class="card-header card-header-primary">
	<h4 class="card-title">修改用户密码</h4>
		<p class="card-category">修改一个用户</p>
	</div>
							<div class="card-body">
							<?php  if(hasinfo()) echo getinfo();?>
								<form  action="adminedit.php"  method="post">
									<div class="row">
										<div class="col-md-12">
											<div class="form-group">
												<label class="bmd-label-floating">用户名</label>
<input type="text" class="form-control" name="adminuser"  disabled  

												value="<?php echo $pan['adminuser']; ?>">
											</div>
										</div>

									</div>
									<div class="row">
										<div class="col-md-12">
											<div class="form-group">
												<label class="bmd-label-floating">旧密码</label>
												<input type="password" class="form-control" 
													name="adminpass" value="" 
												>
											</div>
										</div>

									</div>
									<div class="row">
										<div class="col-md-12">
											<div class="form-group">
												<label class="bmd-label-floating">新密码</label>
												<input type="password" class="form-control" name="newpass">
											</div>
										</div>

									</div>
									<div class="row">
										<div class="col-md-12">
											<div class="form-group">
												<label class="bmd-label-floating">确认密码</label>
												<input type="password" class="form-control" name="okpass">
											</div>
										</div>
									</div>

									<button type="submit" class="btn btn-primary pull-right">修改</button>
									<div class="clearfix"></div>
								</form>
							</div>
						</div>
					</div>

				</div>
	<?php
		require 'foot.php';
	?>